import { getSubject } from '@/services/lessons'
import React, { PureComponent } from 'react'
import { Cascader } from 'antd';
export default class Index extends PureComponent<any, any> {
    state = {
        data: []
    }
    componentDidMount() {
        getSubject().then(res => {
            if (!res || !res[0]) return;
            let data = JSON.stringify(res);
            data = data
                .replace(/id/g, 'value')
                .replace(/title/g, 'label')
                .replace(/pvalue/g, 'pid');
            this.setState({
                data: JSON.parse(data),
            });
        })
    }
    onChange = (e: any, d: any) => {
        this.props.onChange ? this.props.onChange(e, d) : ''
    }
    render() {
        return (
            <Cascader placeholder="请选择科目" onChange={this.onChange} value={this.props.value} style={{ width: 200 }} options={this.state.data} />
        )
    }
}